package com.itheima;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Utils {


    public static void copyFile(InputStream in , OutputStream out){

        try {
            byte[] bytes = new byte[1024];
            int a = -1;
            while ((a = in.read(bytes)) !=-1){
                out.write(bytes,0,a);
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if(in!=null){
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            if (out!=null){
                try {
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
